<template>
  <div>
    <!-- 面包导航区 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="#">权限管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>
      <!-- 搜索 -->
      <el-row>
        <el-col span="8">
          <el-input placeholder="请输入内容">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>

      <!-- 订单信息 -->
      <el-table :data="orderList" border>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.pay_status === '0'"
              >未付款</el-tag
            >
            <el-tag type="success" v-if="scope.row.pay_status === '1'"
              >已付款</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column label="是否发货">
          <template slot-scope="scope">
            {{ scope.row.is_send }}
          </template>
        </el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scope">
            {{ scope.row.create_time | formatDate }}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template>
            <el-button
              @click="showEdit"
              type="primary"
              icon="el-icon-edit"
              size="mini"
            ></el-button>
            <el-button
            @click="showProcess"
              type="success"
              icon="el-icon-location"
              size="mini"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 底部分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>

    <!-- 修改对话框 -->
    <el-dialog
      title="提示"
      :visible.sync="editDialogFlag"
      width="50%"
      @close="closeEditDialog"
    >
      <!-- 表单 -->
      <el-form
        :model="editFormData"
        :rules="editFormDatarules"
        ref="editFormDataref"
        label-width="100px"
      >
        <el-form-item label="省/市区" prop="att1">
          <el-cascader :options="att" v-model="editFormData.att1"></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="att2">
          <el-input v-model="editFormData.att2"></el-input>
        </el-form-item>
      </el-form>
      <!-- 底部 -->
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogFlag = false">取 消</el-button>
        <el-button type="primary" @click="editDialogFlag = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- 展示物流进度对话框 -->
    <el-dialog
      title="物流进度"
      :visible.sync="processDialogFlag"
      width="50%"
      @close="closeProcessDialog"
    >
    接口没写好
      <!-- 表单 -->
      <!-- <el-form
        :model="processFormData"
        :rules="processFormDatarules"
        ref="processFormDataref"
        label-width="100px"
      >
        1
      </el-form> -->
      <!-- 底部 -->
      <span slot="footer" class="dialog-footer">
        <el-button @click="processDialogFlag = false">取 消</el-button>
        <el-button type="primary" @click="processDialogFlag = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>


<script>
import att from "./citydata.js";

export default {
  data() {
    return {
      //查询权限的参数
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      //权限列表
      orderList: [],
      //总数
      total: 0,

      //修改对话框 flag
      editDialogFlag: false,
      //修改 data
      editFormData: {
        att1: [],
        att2: [],
      },
      //地址
      att,
      //验证规则
      editFormDatarules: {
        att1: [],
        att2: [],
      },

      //物流进度对话框 flag
      processDialogFlag:false,
      //物流数据
      processInfo:{},
      //规则
      processFormDatarules:{},

    };
  },
  methods: {
    //获取所有权限列表
    async getOrderList() {
      const { data: res } = await this.$http.get("orders", {
        params: this.queryInfo,
      });
      if (res.meta.status !== 200) return this.$message.error("获取权限失败");
      this.$message.success("获取权限成功");
      this.orderList = res.data.goods;
      this.total = res.data.total;
      console.log(this.orderList);
    },
    //pagesize变化时候触发
    handleSizeChange(val) {
      this.queryInfo.pagesize = val;
      this.getOrderList();
    },
    //当前页面变化时候触发
    handleCurrentChange(val) {
      this.queryInfo.pagenum = val;
      this.getOrderList();
    },
    //展示修改dialog
    showEdit() {
      this.editDialogFlag = true;
    },
    //关闭edit
    closeEditDialog() {
      this.$refs.editFormDataref.resetFields();
    },
    //打开process
    async showProcess(){
      this.processDialogFlag = true
      const {data:res} =await this.$http.get(`/kuaidi/1106975712662`)
      if(res.meta.status!==200)return this.$message.error('获取失败')
      this.processInfo = res.data
      console.log(res);
      
    },
    //关闭prcess
    closeProcessDialog(){
      // this.$refs.processFormDataref.resetFields()
    }
  },
  created() {
    this.getOrderList();
  },
};
</script>


<style lang="less" scoped>
</style>